<template>
    <div class="body-container">
        <div class="back-button" @click="goBack">
            <i class="fa fa-arrow-left"></i>
            返回
        </div>
        <div class="title-section">
            <h1 class="main-title">中医体质文化</h1>
            <p class="subtitle">了解您的体质类型，助力健康生活</p>
        </div>
        <div class="content-container">
            <div class="constitution-circle">
                <!-- 添加 SVG 圆框 -->
                <svg class="circle-frame" width="600" height="600" viewBox="0 0 600 600">
                    <circle cx="300" cy="300" r="270" stroke="#fff" stroke-width="2" fill="none" />
                </svg>
                <div 
                    class="constitution-card" 
                    v-for="(type, index) in constitutionTypes" 
                    :key="type.name"
                    :class="getCardClass(type.name)"
                    :style="{ 
                        transform: `rotate(${index * (360 / constitutionTypes.length) + rotationAngle}deg) translate(400px) rotate(-${index * (360 / constitutionTypes.length) + rotationAngle}deg)` 
                    }"
                >
                    <div class="card-header">
                        <h3>{{ type.name }}</h3>
                    </div>
                    <div class="card-content">
                        <p><strong>症状：</strong>{{ type.symptoms }}</p>
                    </div>
                </div>
            </div>
        </div>

    </div>
</template>

<script>
export default {
    name: 'ConstitutionApp',
    data() {
        return {
            constitutionTypes: [
                {
                    name: '平和体质',
                    symptoms: '精力充沛，语言有力，处事乐观，适应力强。'
                },
                {
                    name: '阳虚体质',
                    symptoms: '手脚发凉，不耐寒冷，容易腹泻、胃脘，胃部或者腰怕冷。'
                },
                {
                    name: '阴虚体质',
                    symptoms: '手脚心发热，口渴干燥，两颊潮红或者绯红。'
                },
                {
                    name: '气虚体质',
                    symptoms: '容易疲乏，声音低弱，喜欢安静，容易感冒。'
                },
                {
                    name: '痰湿体质',
                    symptoms: '腹部胀满结痂，身体沉重，腹部通胀分泌多，上腹黏化肌入肺。'
                },
                {
                    name: '湿热体质',
                    symptoms: '面部通胀感，易生疮疡，口苦口臭，大便粘滞。'
                },
                {
                    name: '气郁体质',
                    symptoms: '情绪低落，容易紧张，多愁善感，容易受到惊吓。'
                },
                {
                    name: '血瘀体质',
                    symptoms: '面部透视有明显，口唇颜色偏暗，皮肤容易出现紫斑，倦怠。'
                },
                {
                    name: '特禀体质',
                    symptoms: '容易过敏，不耐受会打喷嚏，鼻塞、流涕、皮肤容易出现抓痕、起疹。'
                }
            ],
            rotationAngle: 0
        }
    },
    mounted() {
        this.startRotation();
    },
    methods: {
        goBack() {
            this.$router.back()
        },
        getCardClass(typeName) {
            // 为不同体质类型返回不同的CSS类
            const classMap = {
                '平和体质': 'balanced',
                '阳虚体质': 'yang-deficient',
                '阴虚体质': 'yin-deficient',
                '气虚体质': 'qi-deficient',
                '痰湿体质': 'phlegm-dampness',
                '湿热体质': 'dampness-heat',
                '气郁体质': 'qi-stagnation',
                '血瘀体质': 'blood-stasis',
                '特禀体质': 'special-diathesis'
            }
            return classMap[typeName] || ''
        },
        startRotation() {
            const animate = () => {
                this.rotationAngle = (this.rotationAngle + 0.02) % 360;
                requestAnimationFrame(animate);
            };
            animate();
        }
    }
}
</script>

<style scoped>
.body-container {
    min-height: 100vh;
    padding: 0px;
    background: linear-gradient(135deg, #1a1f2c 0%, #2d3748 100%);
    color: #fff;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    font-family: 'Arial', sans-serif;
}

.title-section {
    margin-top: 5vh;
    margin-bottom: 50px;
    text-align: center;
}

.main-title {
    font-size: 64px;
    font-weight: bold;
    margin: 0 0 20px;
    background: linear-gradient(45deg, #00FFFF, #FF00FF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: titleFadeIn 1s ease-in-out;
}

.subtitle {
    color: #e6e6e6;
    font-size: 1.1rem;
}

@keyframes titleFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-container {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.constitution-circle {
    position: relative;
    width: 1000px; 
    height: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: -50px; /* 整体往上移50px，可根据需要调整 */
}

.constitution-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.2) 100%);
    border-radius: 50%;
    width: 120px; 
    height: 120px;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
    position: absolute;
    will-change: transform;
}

.constitution-card:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.3) 100%);
    transform: translateY(-5px) rotate(0deg) translate(400px) rotate(0deg); 
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.card-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.card-header h3 {
    font-size: 1.1rem; 
    color: #00FFFF;
    margin: 0;
}

.card-content p {
    line-height: 1.3; 
    font-size: 0.7rem; 
    margin: 0;
    color: #e6e6e6;
}

/* 不同体质类型的卡片颜色 */
.balanced {
    border-top: 4px solid #4caf50;
}

.yang-deficient {
    border-top: 4px solid #2196f3;
}

.yin-deficient {
    border-top: 4px solid #9c27b0;
}

.qi-deficient {
    border-top: 4px solid #ff9800;
}

.phlegm-dampness {
    border-top: 4px solid #795548;
}

.dampness-heat {
    border-top: 4px solid #f44336;
}

.qi-stagnation {
    border-top: 4px solid #673ab7;
}

.blood-stasis {
    border-top: 4px solid #e91e63;
}

.special-diathesis {
    border-top: 4px solid #607d8b;
}

.footer {
    width: 100%;
    text-align: center;
    padding: 10px 0;
    background-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.2);
    color: #e6e6e6;
    font-size: 16px;
    margin-top: 50px;
    box-sizing: border-box;
}

.circle-frame {
    position: absolute;
    z-index: 1;
}

.back-button {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(0, 255, 255, 0.3) 100%);
    color: #fff;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    z-index: 100;
    font-size: 16px;
}

.back-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
</style>